//
//  UIImage+YSCutIOutCircle.m
//  loveBeen
//
//  Created by 杨烁 on 2016/11/22.
//  Copyright © 2016年 loveBeen. All rights reserved.
//

#import "UIImage+YSCutIOutCircle.h"

@implementation UIImage (YSCutIOutCircle)

-(UIImage*) circleParam:(CGFloat) inset {
    UIGraphicsBeginImageContext(self.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetLineWidth(context, 2);
    CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor);
    CGRect rect = CGRectMake(inset, inset, self.size.width - inset * 2.0f, self.size.height - inset * 2.0f);
    CGContextAddEllipseInRect(context, rect);
    CGContextClip(context);
    
    [self drawInRect:rect];
    CGContextAddEllipseInRect(context, rect);
    CGContextStrokePath(context);
    UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newimg;
}

@end
